@include("template::My.views.header")  
<link href="/mycms/cms/theme/My/assets/css/sms.css?time={{time()}}" rel="stylesheet">
</head>
<body class="bg-[#FFFFFF] font-['PingFang']"  onload="countDown()">
     <p class="text-center pt-[82px] text-[#222222] font-extrabold   font-['PingFang'] text-[23px]">输入验证码</p>
    <form method="post" id="reg"  onsubmit="return register();">
    <div class="container mx-auto bg-white w-11/12  rounded-3xl  flex flex-row justify-center items-center  mb-[57px] mt-[52px]">
        <input type="number" name="c1" id="c1" class="rounded-xl w-[52px]  h-[52px]  bg-[#F6F6F6] text-center text-[#C6C6C6] text-xl mx-[19px]  border-[0px] focus:text-[#222222]  focus:text-[18px]" placeholder="" size="1" onchange="regcode();"/>
        <input type="number" name="c2" id="c2" class="rounded-xl  w-[52px]  h-[52px] bg-[#F6F6F6] text-center text-[#C6C6C6] text-xl mx-[19px]  border-[0px] focus:text-[#222222]  focus:text-[18px]" placeholder="" size="1" onchange="regcode();"/>
        <input  type="number" name="c3"  id="c3" class="rounded-xl  w-[52px]  h-[52px] bg-[#F6F6F6] text-center text-[#C6C6C6] text-xl mx-[19px]  border-[0px] focus:text-[#222222]  focus:text-[18px]" placeholder="" size="1" onchange="regcode();"/>
        <input type="number"  name="c4" id="c4" class="rounded-xl  w-[52px]  h-[52px] bg-[#F6F6F6] text-center text-[#C6C6C6] text-xl mx-[19px]  border-[0px] focus:text-[#222222]  focus:text-[18px]" placeholder="" size="1" onchange="regcode();"/>
    </div>
    <div class="container mx-auto flex flex-col justify-center items-center">
            <input type="hidden" name="mobile" value="{{$mobile}}" id="mobile"/>
            <input type="hidden" name="password" value="{{$pwd}}"  id="password"/>
             @csrf
        <p class="text-[#878787] font-['PingFang'] text-[13px]  mb-[28px]"  id="send_btn">59秒从新获取</p>
        <button  class="bg-[#3368FD] rounded-full shadow-xl shadow-blue-400/30 w-[302px]  h-[50px]  mb-[268px] text-white font-bold text-[18px]">下一步</button>
    </div> 
    </form>
<script>
    var time = 60;
    var send_lock = false;
    function countDown()
    {
        if (time > 0) {
            $('#send_btn').text(time + "秒后从新获取");
            time--;
            setTimeout(countDown,1000);
        } else {
            time = 60;
            send_lock = false;
            $('#send_btn').text("马上发送");
        }
    }
    var code='';
    function regcode(){
        var c1=$('#c1').val(); 
        $('#c1').val(c1.charAt(0)); 
        var c2=$('#c2').val();
        $('#c2').val(c2.charAt(0)); 
        var c3=$('#c3').val(); 
        $('#c3').val(c3.charAt(0)); 
        var c4=$('#c4').val(); 
        $('#c4').val(c4.charAt(0)); 
        code=c1+c2+c3+c4;
        $('#send_btn').val(code); 
    }
    function register()
    {
        var mobile=$('#mobile').val(); 
        var password=$('#password').val(); 
        $.ajax({
            url: '{{route('user.reg')}}',
            type: 'post',
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "json",
            data: {"mobile":mobile,"name":mobile,'password':password,'reg_code':code,'tuid':{{$form}}},
            timeout: 60000,
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            success: function (res) {
                alert(res.msg);
                location.href = "{{route('user.setpw',['referrer'=>$referrer?:url('/')])}}";   
            },
            error: function (xhr) {
               jsonObj=JSON.parse(xhr.response)
               alert(jsonObj.msg);
                return false;
            }
        });
        return false;
    }

</script>
@include("template::My.views._footer")
